package practise;

import java.util.*;

public class Count {
    public static void main(String[] args) {
        String[]arr={"A","B","C","D"};
        List<String>list=new ArrayList<>();
        for (int i = 1; i <=80 ; i++) {
            Random r=new Random();
            int j = r.nextInt(arr.length);
            list.add(arr[j]);
        }

        Map<String,Integer>map=new HashMap<>();
        for (String s : list) {
            //判断是否是第一次
            if (map.containsKey(s)){
                Integer count = map.get(s);
                count++;
                map.put(s,count);
                //不是 数量加一
            }else {
                map.put(s,1);
            }
        }
        //求最大值

        Integer max=0;
        Set<String> strings = map.keySet();
        for (String string : strings) {
           if (max<map.get(string)){
               max=map.get(string);
           }
        }
        System.out.println(max);
        for (String string : strings) {
            if (max.equals(map.get(string))){
                System.out.println(string);
            }
        }
    }
}
